USE [HuberRace]
GO

/****** Object:  View [dbo].[Results]    Script Date: 07/26/2012 21:16:00 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO



CREATE VIEW [dbo].[Results]
AS
SELECT 
	b.place, 
	ISNULL(CONVERT(VARCHAR(50), t.time, 108),'') as time, 
	b.bib, 
	ISNULL(UPPER(p.name),'') as name, 
	ISNULL(p.age,'') as age, 
	ISNULL(UPPER(p.gender),'') as gender, 

	ISNULL(gender + CAST((p.age/10) AS CHAR(1)) + '0','') as AG,
	b.raceId,
	ISNULL(UPPER(p.TeamName),'') as 'TeamName',
	UPPER(isUSATF) as 'isUSATF'

FROM BibOrderPlace b
RIGHT JOIN TimeOrderPlace t ON
    b.place = t.place AND
    t.raceId = b.raceId
LEFT JOIN Participants p ON
    b.bib = p.bib


GO


